<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <th:block th:include="common/common_head :: commonHeader('宣告表详情')"/>
    <link rel="stylesheet" th:href="@{/static/js/plugins/jquery-layout/jquery.layout-latest.css}">
    <style>
        #itemTable td {
            padding: 13px 0px
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div ui-layout-center">
    <div class="row">
        <div shiro:hasPermission="declarationForm:audit" th:if="${head.reviewDate==null}">
            <div class="col-sm-12" style="margin:20px 16px">
                <input class="btn btn-primary" type="button" onclick="audit()" value="提交">
                <button class="btn btn-primary" type="button" onclick="Dialog.closeFrame(window.name)">取 消</button>
            </div>
            <div>
                <label style="float: left;vertical-align: middle;margin-left: 20px;"><span class="required-sign">*</span>审核意见：</label>
                <div  class="col-sm-2">
                    <select id="nodeStatus" class="form-control" name="nodeStatus" required>
                        <option></option>
                        <option value="1">通过</option>
                        <option value="2">退回</option>
                        <option value="3">淘汰</option>
                    </select>
                </div>
            </div>
            <input id="headId" type="text" th:value="${head.pkId}" hidden>
        </div>
        <div class="col-sm-12 select-info">
            <form id="substanceForm" class="form-horizontal" method="post">
                <div class="ibox float-e-margins">
                    <div class="table-responsive">
                        <table class="layui-table" style="margin: 0 auto;text-align: center ;font-size: 13px">
                            <thead>
                            <tr>
                                <th colspan="8" style="font-size: 19px;text-align: center;">产品/部件宣告表
                                    <br>Product/Component Declaration From
                                </th>
                                <th style="font-size: 12px;">编号：RoHS-01
                                    <br> 生效期：<span th:text="${#dates.format(head.declarationDate,'yyyy-MM-dd')}"></span>
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td rowspan="4" width="11%">基本信息
                                    <br>Basal Information
                                </td>
                                <td width="12%" style="text-align: center">专用号
                                    <br>No.
                                </td>
                                <td id="materialCode" width="10%" th:text="${head.materialCode}"></td>
                                <td width="14%" style="text-align: center">产品/部件名称
                                    <br>Name
                                </td>
                                <td id="materialDesc" width="10%" th:text="${head.materialDesc}"></td>
                                <td style="text-align: center">供应商
                                    <br>Supplied By
                                </td>
                                <td id="vendorName" width="10%" th:text="${head.vendorName}"></td>
                                <td width="10%" style="text-align: center">供应商代码
                                    <br>V Code
                                </td>
                                <td id="vendorCode" width="12%" th:text="${head.vendorCode}"></td>
                            </tr>
                            <tr>
                                <td>QC080000体系
                                    <br>QC080000 system
                                </td>
                                <td th:if="${head.qc080000==0}">通过</td>
                                <td th:if="${head.qc080000==1}">不通过</td>
                                <td>RoHS承诺书编号
                                    <br>RoHS Guarante No
                                </td>
                                <td id="guaranteeCode" th:text="${head.guaranteeCode}"></td>
                                <td>宣告日期
                                    <br>Declartion Date
                                </td>
                                <td id="declarationDate"
                                    th:text="${#dates.format(head.declarationDate,'yyyy-MM-dd')}"></td>
                                <td>宣告表编号
                                    <br>Declaration No
                                </td>
                                <td id="formCode" th:text="${head.formCode}"></td>
                            </tr>
                            <tr>
                                <td>模块商联系人
                                    <br>Contact Person
                                </td>
                                <td id="contacter" th:text="${head.contacter}"></td>
                                <td>联系电话
                                    <br>Telephone Number
                                </td>
                                <td id="telephone" th:text="${head.telephone}"></td>
                                <td>地址
                                    <br>Address
                                </td>
                                <td id="address" th:text="${head.address}"></td>
                                <td>申请审核工厂
                                    <br>Apply for factory audit
                                </td>
                                <td id="verifyFactory" th:text="${head.verifyFactory}"></td>
                            </tr>
                            <tr>
                                <td colspan="2">材料组成相同的关联专用号
                                    <br>Special code for the same material com
                                </td>
                                <td id="relateMaterialCode" colspan="2"
                                    th:text="${head.relateMaterialCode}"></td>
                                <td colspan="2">关联供货工厂
                                    Supply For
                                </td>
                                <td id="relateSupplier" colspan="2" th:text="${head.relateSupplier}"></td>
                            </tr>
                            </tbody>
                        </table>
                        <!-- item的表格-->
                        <table class="layui-table" style="margin: 0 auto;text-align: center; font-size: 13px"
                               id="itemTable">
                            <tbody>
                            <tr>
                                <td rowspan="2">序号</td>
                                <td colspan="5">子部件/原料</td>
                                <td colspan="3">均质材料</td>
                                <td colspan="6">第三方测试</td>
                                <td colspan="10">限制使用物质名称</td>
                                <td rowspan="2">是否豁免项</td>
                            </tr>
                            <tr>
                                <td> 名称</td>
                                <td> 规格型号</td>
                                <td> 供应商</td>
                                <td>数量</td>
                                <td>重量(g)</td>
                                <td> 名称</td>
                                <td> 规格型号</td>
                                <td>重量(g)</td>
                                <td>委托单位全称</td>
                                <td>检测机构</td>
                                <td>测试报告编号</td>
                                <td>报告附件</td>
                                <td>报告日期</td>
                                <td>有效期至</td>
                                <td>Pb</td>
                                <td> Cd</td>
                                <td>Hg</td>
                                <td>Cr(VI)</td>
                                <td>PBB</td>
                                <td>PBDE</td>
                                <td>DEHP</td>
                                <td>DBP</td>
                                <td>BBP</td>
                                <td>DIBP</td>
                            </tr>
                            <tr th:each="declarationDetial , stus : ${declarationDetails}">
                                <td name="pkId" type="text" th:value="${declarationDetial.pkId}" hidden></td>
                                <td th:text="${stus.index+1}"></td>
                                <td th:text="${declarationDetial.compName}"></td>
                                <td th:text="${declarationDetial.compType}"></td>
                                <td th:text="${declarationDetial.compSupplier}"></td>
                                <td th:text="${declarationDetial.compQuantity}"></td>
                                <td th:text="${declarationDetial.compWeight}"></td>
                                <td th:text="${declarationDetial.homegeName}"></td>
                                <td th:text="${declarationDetial.homegeType}"></td>
                                <td th:text="${declarationDetial.homegeWeight}"></td>
                                <td th:text="${declarationDetial.thirdCompany}"></td>
                                <td th:text="${declarationDetial.thirdInstitution}"></td>
                                <td th:text="${declarationDetial.thirdReport}"></td>
                                <td><a style="color: blue" onclick="dowloadFileById(this)" th:value="${declarationDetial.pkId}" th:text="${declarationDetial.thirdAttachment}"></a></td>
                                <td th:text="${#dates.format(declarationDetial.thirdReportdate,'yyyy-MM-dd')}"></td>
                                <td th:text="${#dates.format(declarationDetial.thirdExpiredate,'yyyy-MM-dd')}"></td>
                                <td th:text="${declarationDetial.pb}"></td>
                                <td th:text="${declarationDetial.cd}"></td>
                                <td th:text="${declarationDetial.hg}"></td>
                                <td th:text="${declarationDetial.cr}"></td>
                                <td th:text="${declarationDetial.pbb}"></td>
                                <td th:text="${declarationDetial.pbde}"></td>
                                <td th:text="${declarationDetial.dehp}"></td>
                                <td th:text="${declarationDetial.dbp}"></td>
                                <td th:text="${declarationDetial.bbp}"></td>
                                <td th:text="${declarationDetial.dibp}"></td>
                                <td th:text="${declarationDetial.exemption}"></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<script type="text/javascript" th:src="@{/static/js/plugins/jquery-layout/jquery.layout-latest.js}"></script>

<script type="text/javascript">

    /**
     **根据id下载报告文件
     **
     **/
    function dowloadFileById(obj) {
        var id=$(obj).first().attr("value");
        window.location.href = ctxPath + "/declarationForm/downloadFileById?id=" + id;
    }

    /**
     * 审核
     */
    function audit() {
        let nodeStatus=$("#nodeStatus").val();
        if(!nodeStatus){
            Dialog.errorMsg("请选择审核意见！");
            return false;
        }
        let headId=$("#headId").val();

        layer.load(1, {shade: [0.3, '#393D49']});
        $.ajax({
            type: "POST",
            url: ctxPath + "/declarationForm/audit",
            data: {"nodeStatus":nodeStatus,"headId":headId},
            dataType:"json",
            error: function () {
                layer.closeAll();
                Dialog.errorMsg("操作失败！");
            },
            success: function (data) {
                if (data.code == 0) {
                    Dialog.msg("操作成功!");
                    parent.refresh();
                    Dialog.closeFrame(window.name);
                } else {
                    layer.closeAll();
                    Dialog.errorMsg("操作失败，请重试!");
                }
            }
        });
    }

</script>

</body>
</html>